//
//  MainTableViewController.swift
//  微博项目
//
//  Created by 英 on 15/12/12.
//  Copyright © 2015年 英. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {
    // 必选的属性
    let mainTabBar = MainTabBar()

    override func viewDidLoad() {
        super.viewDidLoad()

        mainTabBar.composeBtn.addTarget(self, action: "composeBtnDidClick", forControlEvents: .TouchUpInside)
        setValue(mainTabBar, forKey: "tabBar")
       
        // 添加子视图
        addChildViewControllers()
      
    }
    
  @objc  private func composeBtnDidClick() {
    // 点击加号按钮的事件
        
    }

    private func addChildViewControllers() {
        self.tabBar.tintColor = UIColor.orangeColor()
        addChildViewController(HomeTableViewController(),title:"首页",imageName:"tabbar_home")
        addChildViewController(DiscoverTableViewController(),title: "发现",imageName: "tabbar_discover")
        addChildViewController(MessageTableViewController(),title: "消息",imageName: "tabbar_message_center")
        addChildViewController(MeTableViewController(),title: "我",imageName: "tabbar_profile")
    }
    
    private func addChildViewController(vc: UIViewController ,title :String ,imageName :String) {
        let nav = UINavigationController(rootViewController: vc)
        
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        
        self.addChildViewController(nav)
    }
}



